#define N 1024*1024
float dotprod(float B[], float C[]) {
    float sum = 0.0;
    int i;
    #pragma omp target map(to: B[0:N], C[0:N]) map(tofrom: sum)
    #pragma omp teams num_teams(8) thread_limit(16) reduction(+:sum)
    #pragma omp distribute parallel for reduction(+:sum) \
            dist_schedule(static, 1024) schedule(static, 64)
    for(i=0; i<N; i++)
        sum += B[i] * C[i];
    return sum;
}

int main() {
    float *B, *C;
    B = (float *)malloc(N*sizeof(float));
    C = (float *)malloc(N*sizeof(float));
    for(int i=0; i<N; i++) {
        B[i] = 1.0f;
        C[i] = 2.0f;
    }
    float result = dotprod(B, C);
    printf("Result: %f\n", result);
    return 0;
}